﻿using System;
using System.Collections;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using System.Collections.Generic;

namespace YXShop.Web.filehandle
{
    /// <summary>
    /// $codebehindclassname$ 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class product_Info : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            if (ChangeHope.WebPage.PageRequest.GetFormString("Option") != string.Empty && ChangeHope.WebPage.PageRequest.GetFormString("productId") != string.Empty)
            {
                YXShop.Common.PromptInfo.Popedom("001008003", "对不起，您没有删除的权限");
                string types = ChangeHope.WebPage.PageRequest.GetFormString("Option");
                string productId = ChangeHope.WebPage.PageRequest.GetFormString("productId");
                string valueId = ChangeHope.WebPage.PageRequest.GetFormString("valueId");
                switch (types)
                {
                    case "productAlumb":
                        string albumInfo = YXShop.TemplateAction.Common.ProductAlbum(productId, "", "", "", true, Convert.ToInt32(valueId));
                        context.Response.Write(albumInfo);
                        break;
                    case "productData":
                        string specificationsValue = ChangeHope.WebPage.PageRequest.GetFormString("SpecificationsValue");
                        YXShop.BLL.Product.ProductSpecification ps = new YXShop.BLL.Product.ProductSpecification();
                        List<YXShop.Model.Product.ProductSpecification> psList = ps.GetSpecification(" and ProductId=" + productId + " and Specifications='" + specificationsValue + "'");
                        if (psList.Count > 0)
                        {
                            double price = 0;
                            int productCount = 0;
                            double integarl = 0;
                            string productGoodNo = "";
                            string reStr = "";
                            price = Convert.ToDouble(psList[0].SalePrice.ToString());
                            string memberPrice = psList[0].MemberPrice;
                            if (context.Session != null && context.Session["MemberID"] != null)
                            {
                                price =YXShop.Common.ProductInfo.DiscountedPrice(int.Parse(HttpContext.Current.Session["MemberID"].ToString()), price, memberPrice);
                            }
                            productCount = psList[0].ProductStock;
                            integarl = Convert.ToDouble(psList[0].IntegralToBuy.ToString());
                            productGoodNo = psList[0].ProductCode;
                            reStr = price + "v_space" + integarl.ToString("f2") + "v_space" + productCount + "v_space" + productGoodNo;
                            context.Response.Write(reStr);
                        }
                        break;
                }
                context.Response.End();
                return;
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}
